import java.util.Arrays;
import java.io.FileReader;
import java.io.BufferedReader;

public class Problem22 {
	public static void main(String[] args) {
		long sum = 0;
		try {
			BufferedReader br = new BufferedReader(new FileReader("p022_names.txt"));

			String line = null;
			while ((line = br.readLine()) != null) {
				String[] strs = line.split(",");
				
				Arrays.sort(strs);

				for (int i = 0; i < strs.length; ++i) {
					sum += alphabeticalValue(strs[i].substring(1, strs[i].length()-1))*(i+1);
				}
			}

			br.close();
		} catch (Exception e) {
		}

		System.out.println("" + sum);
	}

	private static int alphabeticalValue(String s) {
		int sum = 0;
		for (int i = 0; i < s.length(); i++)
			sum += s.charAt(i) - 'A' + 1;

		return sum;
	}
}
